<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:display="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>EasyInvoke控制台</title>
    <link th:href="@{/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/font-awesome.min.css}" rel="stylesheet">
    <link th:href="@{/animate.min.css}" rel="stylesheet">
    <link th:href="@{/style.min.css}" rel="stylesheet">
</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">

                    <div th:if="${resourceList} != null">
                        <h2>
                            为您找到相关结果约<span th:text="${resourceList.size()}"/>个： <span class="text-navy">“<span
                                th:text="${beanName}"/>”</span>
                        </h2>
                        <small>搜索用时 (0.03秒)</small>
                    </div>
                    <div th:if="${resourceList} == null">
                        <h2>
                            欢迎使用 <span class="text-navy">EasyInvoke</span>
                        </h2>
                        <small>可在下方输入您要invoke的BeanName</small>
                    </div>

                    <div class="search-form">
                        <div class="input-group">
                            <div style="display: none;"><span id="domain" th:text="${domain}"></span></div>
                            <input type="text" placeholder="beanName" id="invokeTarget" name="search"
                                   class="form-control input-lg">
                            <div class="input-group-btn">
                                <button class="btn btn-lg btn-primary" type="button"
                                        th:onclick="'javascript:searchInvokeMethod();'">
                                    搜索
                                </button>
                            </div>
                        </div>

                    </div>

                    <div th:if="${resourceList} != null" th:each="resource : ${resourceList}">
                        <div class="hr-line-dashed"></div>
                        <div class="search-result">
                            <h3><a href="#" th:onclick="'javascript:prepare(\'' + ${resource.code} + '\');'"><span
                                    th:text="${resource.method.name}"/></a></h3>
                            参数：
                            <sapn href="#" class="search-link" th:each="paramType : ${resource.method.params}"><span
                                    th:text="${paramType.type}"/>;&nbsp;
                            </sapn>
                            <p>
                                返回值：&nbsp; <span th:text="${resource.method.returnType}"/>
                            </p>
                        </div>
                    </div>

                    <div th:if="${exception} != null">
                        <div class="hr-line-dashed"></div>
                        <div class="search-result">
                            <p th:text="${exception}"/>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/jquery.min.js}"></script>
<script th:src="@{/bootstrap.min.js}"></script>

</body>

<script type="text/javascript" th:inline="javascript">

    document.onkeydown = function (e) {
        var ev = document.all ? window.event : e;
        if (ev.keyCode == 13) {
            searchInvokeMethod();
        }
    }

    function searchInvokeMethod() {

        var target = $('#invokeTarget').val();
        var domain = $('#domain').html();
        var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];

        window.location.href = basePath + "" + domain + "/easy-invoke/search/" + target;
    };

    function prepare(code) {

        var domain = $('#domain').html();
        var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];

        window.location.href = basePath + "" + domain + "/easy-invoke/prepare/" + code;
    };
</script>

</html>
